<template>
  <div id="app">
    <h2>测试题</h2>
    <SubjectItem @submitFn="submitFn2"></SubjectItem>
    <div>
      <FlagItem :statusArr="statusArr"></FlagItem>
    </div>
  </div>
</template>

<script>
import FlagItem from './components/FlagItem.vue';
import SubjectItem from './components/SubjectItem.vue';


export default {
  data() {
    return {
      statusArr: ["未完成", "未完成", "未完成", "未完成", "未完成"],
    };
  },
  components:{
    SubjectItem,
    FlagItem
  },
   methods: {
    submitFn2(val1, val2,index) {
      
      if (val1 == val2) {
        this.statusArr.splice(index,1,'回答正确')
      } else if (val1 != val2) {
        if (val2 == undefined) {
        this.statusArr.splice(index,1,'未完成')
        } else {
        this.statusArr.splice(index,1,'回答错误')
        }
      }
    },
  },
};
</script>

<style>
body {
  background-color: #eee;
}

#app {
  background-color: #fff;
  width: 500px;
  margin: 50px auto;
  box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.5);
  padding: 2em;
}
</style>